import unittest

from model.storage.memoryManager import WorseFitBlock
from model.storage.memoryManager import Block

class BestFitBlockCase(unittest.TestCase):
    
    def testWhenSizeIs2ThenReturnBlock2(self):
        blocks = []
        block1 = Block(11,15,2)
        block2 = Block(0,10,1) 
        block3 = Block(16,17,3)
        blocks.append(block1)
        blocks.append(block2)
        blocks.append(block3)
        worseFit = WorseFitBlock()
        blockResult = worseFit.getEmptyBlock(blocks, 2)
        self.assertEqual(blockResult,block2)
        self.assertEqual(len(blocks),2)
        
    def testWhenSizeIs2ThenNotReturnBlock1or3(self):
        blocks = []
        block1 = Block(11,15,2)
        block2 = Block(0,10,1) 
        block3 = Block(16,17,3)
        blocks.append(block1)
        blocks.append(block2)
        blocks.append(block3)
        worseFit = WorseFitBlock()
        blockResult = worseFit.getEmptyBlock(blocks, 2)
        self.assertNotEquals(blockResult,block1)
        self.assertNotEquals(blockResult,block3)
        

def main():
    unittest.main()

if __name__ == "__main__":
    main()
